﻿<Window
   xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
   xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
   xmlns:d="http://schemas.microsoft.com/expression/blend/2006" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="d"
   xmlns:System="clr-namespace:System;assembly=mscorlib"
   xmlns:er="clr-namespace:Microsoft.EnhancedReminders.OutlookAddIn"
   xmlns:properties="clr-namespace:Microsoft.EnhancedReminders.Properties"
   xml:lang="en-US"
   x:Class="Microsoft.EnhancedReminders.OutlookAddIn.AddEditChannelDialog"
   x:Name="Window"
   ResizeMode="NoResize"
   SizeToContent="WidthAndHeight">

   <Window.Resources>
      <Thickness x:Key="MarginsAndPaddings">10,0,0,10</Thickness>
      <System:Double x:Key="ButtonSize">50</System:Double>
   
      <DataTemplate x:Key="channelListBox" DataType="ChannelItem">
         <StackPanel Orientation="Horizontal">   
            <Image HorizontalAlignment="Left" Width="16" Height="16" x:Name="selectionIcon" Source="{Binding Path=ImageSource}"/>
            <TextBlock HorizontalAlignment="Left" x:Name="selectionName" Grid.Column="1" Text="{Binding Path=DisplayName}" Margin="2,2,2,2"/>             
         </StackPanel>         
      </DataTemplate>
      <Thickness x:Key="CheckboxMargins">0,0,0,10</Thickness>
      <System:Int32 x:Key="MaxTextBoxLength">256</System:Int32>
   </Window.Resources>

   <Grid Margin="10,0,10,0">
      <Grid.ColumnDefinitions>
         <ColumnDefinition/>
      </Grid.ColumnDefinitions>
      <Grid.RowDefinitions>
         <RowDefinition/>
         <RowDefinition/>
      </Grid.RowDefinitions>

      <Grid Margin="0,10,0,0">
         <Grid.ColumnDefinitions>
            <ColumnDefinition MinWidth="100" />
            <ColumnDefinition/>
         </Grid.ColumnDefinitions>
         <Grid.RowDefinitions>
            <RowDefinition/>
            <RowDefinition/>
            <RowDefinition/>
            <RowDefinition/>
            <RowDefinition/>
            <RowDefinition/>
         </Grid.RowDefinitions>      
         
         <Label x:Uid="selectChannelLabel" Content="{x:Static properties:Resources.ChannelDialogSelectChannelLabel}"/>
         <ComboBox x:Name="selectChannel" x:Uid="selectChannel" 
            IsSynchronizedWithCurrentItem="True" SelectedValuePath="ChannelType"
            Grid.Column="1" Grid.ColumnSpan="1" 
            ItemTemplate="{StaticResource channelListBox}"
            Margin="{DynamicResource MarginsAndPaddings}"         
            SelectedValue="{Binding Path=NotificationChannelType, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"/>

         <Label x:Uid="nameLabel" Grid.Row="1" Content="{x:Static properties:Resources.ChannelDialogNameLabel}" />
         <TextBox x:Name="nameText" x:Uid="nameText" Grid.Row="1" Grid.Column="1" 
            MinWidth="200" MaxWidth="200" MaxLength="{DynamicResource MaxTextBoxLength}"
            Margin="{DynamicResource MarginsAndPaddings}"
            Text="{Binding Path=UserDefinedName, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"/>

         <Label x:Uid="addressLabel" Grid.Row="2"            
            Content="{Binding Path=SelectedItem.AddressIdentifier, ElementName=selectChannel}" />
         <TextBox x:Name="addressText" x:Uid="addressText" MinWidth="200" MaxWidth="200" Grid.Row="2" Grid.Column="1" Margin="{DynamicResource MarginsAndPaddings}"
            Text="{Binding Path=UserDefinedValue, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" MaxLength="{DynamicResource MaxTextBoxLength}"/>      
         
         <Label x:Uid="exampleLabel" Grid.Row="3" Grid.Column="1" Margin="10,-5,0,0"
            Content="{Binding Path=SelectedItem.ExampleText, ElementName=selectChannel}" />
      </Grid>

      <Grid x:Uid="ButtonsAndCheckboxes" Grid.Row="1" Margin="5,0,0,0">
         <Grid.ColumnDefinitions>
            <ColumnDefinition/>
            <ColumnDefinition Width="Auto"/>
            <ColumnDefinition Width="Auto"/>
         </Grid.ColumnDefinitions>
         <Grid.RowDefinitions>
            <RowDefinition/>
            <RowDefinition/>
            <RowDefinition/>
         </Grid.RowDefinitions>      

         <CheckBox x:Uid="isEnabled"
            IsChecked="{Binding Path=IsEnabled, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" 
            Click="isEnabled_Clicked"
            Content="{x:Static properties:Resources.ChannelDialogEnable}" Margin="{DynamicResource CheckboxMargins}"/>
         
         <CheckBox x:Name="isTopOfList"  x:Uid="isTopOfList"
            Grid.Row="1" Content="{x:Static properties:Resources.ChannelDialogAddToTop}" IsChecked="True" Margin="{DynamicResource CheckboxMargins}"/>

         <Button x:Name="okButton" x:Uid="okButton" IsDefault="true"
            Grid.Column="1" Grid.Row="2" 
                IsEnabled="{Binding Path=IsChannelValid, ElementName=Window, Mode=OneWay, UpdateSourceTrigger=PropertyChanged}"
            Width="{DynamicResource ButtonSize}" Margin="{DynamicResource MarginsAndPaddings}" Click="OkButtonClicked" Content="{x:Static properties:Resources.OkButton}"/>
                
         <Button x:Uid="cancelButton" IsCancel="true"
            Grid.Column="2" Grid.Row="2" 
            Width="{DynamicResource ButtonSize}" 
            Margin="{DynamicResource MarginsAndPaddings}" Content="{x:Static properties:Resources.CancelButton2}"/>
      </Grid>      
   </Grid>   
</Window>